package cn.wolfcode.trip.base.domain;

import cn.wolfcode.trip.base.util.DateUtil;
import cn.wolfcode.trip.base.util.JSONUtil;
import lombok.Getter;
import lombok.Setter;
import org.springframework.format.annotation.DateTimeFormat;

import java.util.Date;
import java.util.HashMap;

@Getter
@Setter
public class TravelCommend extends BaseDomain{
    public static final int TYPE_WEEK=1;//每周推荐
    public static final int TYPE_MONTH=2;//每月推荐
    public static final int TYPE_STRATEGY=3;//攻略推荐
    //游记的id
    private Long travelId;

    private String title;

    private String subTitle;

    private String coverUrl;

    @DateTimeFormat(pattern = "yyyy-MM-dd")
    private Date schedule;

    private Integer type=TYPE_WEEK;

    public String getTypeName(){
        String msg="每周推荐";
        if(this.type==2){
            msg="每月推荐";
        }else if(this.type==3){
            msg="攻略推荐";
        }
        return msg;
    }

    public String getJson(){
        HashMap map = new HashMap<>();
        map.put("id",id);
        map.put("travelId",travelId);
        map.put("title",title);
        map.put("subTitle",subTitle);
        map.put("coverUrl",coverUrl);
        map.put("schedule", DateUtil.formatDate(schedule));
        map.put("type", type);
        return JSONUtil.toJSONString(map);
    }
}